#ifndef UPS_DATA_H
#define UPS_DATA_H

#include <QtCore>

//UPS设备
class CUpsData
{
public:
    bool IsCommNormal();
    bool IsCommFault();

    bool IsRunning();
    bool IsStopped();

    bool IsFault();
    bool IsNoFault();

    bool IsAlarm();
    bool IsNoAlarm();

    bool IsOpening();
    bool IsClosed();

    //获取***的显示文本
    QString GetCommStateText();

    void InitToInvalid();
    void InitToZero();
    void InitToValue(quint16 uvalue, float fvalue);

public:
    quint16 m_uCommState;           //7801 通讯状态 0--正常,1-故障
    quint16 m_uRev[99];
    float m_fRev[100];

    //转发的100个UINT16数据
    quint16 m_uRunState;            //7802 运行状态 0运行,1停止
    quint16 m_uFaultState;          //7803 故障状态 0正常,1故障
    quint16 m_uAlarmState;          //7804 告警状态 0正常,1告警
    quint16 m_uSwitchState;         //7805 开关机状态 0已开机,1已关机
    quint16 m_uWorkMode;            //7806 工作模式 1市电,2测试,3旁路,4待机
    quint16 m_uPhaseState;          //7807 单相状态

    quint16 m_uData[94];            //7808~8000 转发的UINT16数据:预留,数组数量=100-上面的转发数

    //转发的100个FLOAT数据
    float m_fPhaseInputVol;         //8001 单相输入电压，单位为V
    float m_fPhaseInputFreq;        //8003 单相输入频率，单位为HZ
    float m_fPhaseOutputVol;        //8005 单相输出电压，单位为V
    float m_fPhaseOutputLoad;       //8007 单相输出负载
    float m_fPhaseBatVol;           //8009 单相电池电压，单位为V

    float m_fPhaseInnerTemp;        //8011 单相机内温度，单位为℃
    float m_fData[94];              //8013~8399 转发的FLOAT数据:预留,数组数量=100-上面的转发数

    // 7801     8000	200	UINT16	200	读预留1设备的UNIT16数据	0x03/0x04	无	预留设备1数据
    // 8001     8400	400	FLOAT	200	读预留1设备的FLOAT数据	0x03/0x04	无
    // 22601	22800	200	UINT16	200	写预留1设备的数据	0x03/0x04	0x06

    //22601~22800 设置的数据:预留,数组数量=100-上面的设置数
    float m_fSetData[100];
    float m_fSetDataCopy[100];
    //上面100个浮点设置值
    //下面100个整形设置值
    quint16 m_uSetBatTest10Seconds;     // 电池测试10s
    quint16 m_uSetBatTest10SecondsCopy;
    quint16 m_uSetBatLowVolTest;        // 电池低压测试
    quint16 m_uSetBatLowVolTestCopy;
    quint16 m_uSetBuzzerSwitch;         // 蜂鸣器开关
    quint16 m_uSetBuzzerSwitchCopy;
    quint16 m_uSetCancelTestCmd;       // 取消测试命令
    quint16 m_uSetCancelTestCmdCopy;
    quint16 m_uSetCancelCloseCmd;       // 取消关机命令
    quint16 m_uSetCancelCloseCmdCopy;

    quint16 m_uSetBatTestNminutes;      // 电池测试N分钟
    quint16 m_uSetBatTestNminutesCopy;
    quint16 m_uSetShutdownAfterNseconds;// 定时N秒后关机
    quint16 m_uSetShutdownAfterNsecondsCopy;
    quint16 m_uSetRebootAfterNminutes; // 定时关机后N分钟再重启UPS
    quint16 m_uSetRebootAfterNminutesCopy;
    quint16 m_uSetSwitchState;      //下设开关机:0关机,1开机
    quint16 m_uSetSwitchStateCopy;
    quint16 m_uSetShutdownAndReboot;    //关机并重启
    quint16 m_uSetShutdownAndRebootCopy;

    quint16 m_uSetData[90];
    quint16 m_uSetDataCopy[90];
};

#endif //UPS_DATA_H
